package com.aqie.easy.utils;

import com.aqie.easy.structure.TreeNode;

public class BinarySearchUtil {
    public static TreeNode node;
    /**
     * 创建二分搜索树
     */
    public static TreeNode createBinarySearchTree(int val){
        if (node == null){
            node = new TreeNode(val);
        }else if (node.val < val){
           node.right = createBinarySearchTree(val);
        }else if(node.val > val){
           node.left = createBinarySearchTree(val);
        }
        return node;
    }

    public static void inOrder(TreeNode node){
        if (node != null) {
            inOrder(node.left);
            System.out.println(node.val);
            inOrder(node.right);
        }
    }
}
